package com.zzptc.myapp1125;

import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.DialogTitle;

import android.os.Bundle;
import android.util.Log;

import com.google.gson.Gson;
import com.zzptc.myapp1125.entity.Students;

public class Main2Activity extends AppCompatActivity {
    private static final String TAG = "Main2Activity";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main2);
        Gson gson=new Gson();
        //language=JSON
        String string="{\n" +
                "  \"code\": 1,\n" +
                "  \"data\": [{\n" +
                "    \"stu_id\": 1,\n" +
                "    \"stu_name\": \"张三\",\n" +
                "    \"stu_age\":20\n" +
                "  },{ \"stu_id\": 2,\n" +
                "    \"stu_name\": \"李四\",\n" +
                "    \"stu_age\":20}]\n" +
                "}";
        Students students=gson.fromJson(string,Students.class);
        Log.d(TAG,"OnCreate:"+students.getData().get(0).getStu_name());
        Log.d(TAG,"onCreate:"+gson.toJson(students));


}
}
